<?php
class Header extends Renderable {
	
	private $text;
	private $leftButton;
	private $rightButton;
	
	public function __construct(Text $text, $elementId = NULL) {
		
		parent::__construct($elementId);
		
		$this->text = $text;
	}
	
	public function setLeftButton(Button $leftButton) {
		
		$this->leftButton = $leftButton;
	}
	
	public function setRightButton(Button $rightButton) {
		
		$attribute = new Attribute('class', 'ui-btn-right');
		$rightButton->addAttribute($attribute);
		$this->rightButton = $rightButton;
	}
	
	protected function renderElement() {
		
		echo '<div data-role="header"', $this->formatAttributes(), ' >';
		
		if (isset($this->leftButton)) {
			$this->leftButton->render();
		}
		
		$this->text->render();
		
		if (isset($this->rightButton)) {
			$this->rightButton->render();
		}
		
		echo '</div>';
	}
	
}
?>